package analysis;
import java.io.*;
import java.util.*;
public class GetUserSet {
	private static final String trainFile = "D:/Users/Nova/Desktop/work/Rec/data/train.txt";
	private static final String testFile = "D:/Users/Nova/Desktop/work/Rec/data/test.txt";
	
	static HashSet<Integer> trainUserA;
	static HashSet<Integer> trainUserB;
	
	static HashSet<Integer> testUserA;
	static HashSet<Integer> testUserB;
	
	static void loadData(String fileName,Set<Integer> set1, Set<Integer> set2)	throws IOException{
		BufferedReader br = new BufferedReader(new FileReader(fileName));
		String line = br.readLine();line = br.readLine();
		int lineCount = 0;
		
		while(line != null && line.length() > 0)	{
			
			
			String[] currentLines = line.split("\\s+");
			set1.add(new Integer(currentLines[0]));
			set2.add(new Integer(currentLines[1]));
			if(++lineCount % 1000000 == 0)
				System.out.println(lineCount);
			
			line = br.readLine();
		}
	}
	static void caculate(Set<Integer> set1, Set<Integer> set2){
		int countOnly1 = 0, count12 = 0,countOnly2  = 0;
		for(Integer id: set1){
			if(!set2.contains(id))
				countOnly1++;
			else {
				count12++;
			}
		}
		for(Integer id: set2){
			if(!set1.contains(id))
				countOnly2++;
		}
		System.out.println("Size: " + set1.size() + " " +set2.size());
		System.out.println(countOnly1+ " " + count12 + " " + countOnly2);
	}
	public static void main(String[] args) throws IOException{
		trainUserA = new HashSet<Integer>();
		trainUserB = new HashSet<Integer>();
		testUserA = new HashSet<Integer>();
		testUserB = new HashSet<Integer>();
		loadData(trainFile,trainUserA,trainUserB);
		loadData(testFile,testUserA,testUserB);
		
		caculate(trainUserA,testUserA);
		caculate(trainUserB,testUserB);
		
	}

}
